Changes the position and/or size of the specified window.
WinMove, X, Y
WinMove, WinTitle, WinText, X, Y [, Width, Height, ExcludeTitle, ExcludeText]
X, Y | The X and Y coordinates (in pixels) of the upper left corner of the target window's new location, which can be expressions. The upper-left pixel of the screen is at 0, 0. If these are the only parameters given with the command, the Last Found Window will be used as the target window. |
WinTitle | The title or partial title of the target window (the matching behavior is determined by SetTitleMatchMode). If this and the other 3 window parameters are blank or omitted, the Last Found Window will be used. If this is the letter A and the other 3 window parameters are blank or omitted, the active window will be used. To use a window class, specify ahk_class ExactClassName (shown by Window Spy). To use a process identifier (PID), specify ahk_pid %VarContainingPID%. To use a window group, specify ahk_group GroupName. To use a window's unique ID number, specify ahk_id %VarContainingID%. The search can be narrowed by specifying multiple criteria. For example: My File.txt ahk_class Notepad |
WinText | If present, this parameter must be a substring from a single text element of the target window (as revealed by the included Window Spy utility). Hidden text elements are detected if DetectHiddenText is ON. |
Width, Height | The new width and height of the window (in pixels), which can be expressions. If either is omitted, blank, or the word DEFAULT, the size in that dimension will not be changed. |
ExcludeTitle | Windows whose titles include this value will not be considered. |
ExcludeText | Windows whose text include this value will not be considered. |
If Width and Height are small (or negative), the window will go no smaller than 112 x 27 pixels. If Width and Height are large, the window will go no larger than approximately 12 pixels beyond the dimensions of the desktop.
Negative values are allowed for the x and y coordinates to support multi-monitor systems and to allow a window to be moved entirely off screen.
Although WinMove cannot move minimized windows, it can move hidden windows if DetectHiddenWindows is on.
Window titles and text are case sensitive. Hidden windows are not detected unless DetectHiddenWindows has been turned on.
ControlMove, WinGetPos, WinHide, WinMinimize, WinMaximize, WinSet
Run, calc.exe WinWait, Calculator WinMove, 0, 0 ; Move the window found by WinWait to the upper-left corner of the screen. SplashTextOn, 400, 300, Clipboard, The clipboard contains:`n%clipboard% WinMove, Clipboard, , 0, 0 ; Move the splash window to the top left corner. Msgbox, Press OK to dismiss the SplashText SplashTextOff ; The following function centers the specified window on the screen: CenterWindow(WinTitle) { WinGetPos,,, Width, Height, %WinTitle% WinMove, %WinTitle%,, (A_ScreenWidth/2)-(Width/2), (A_ScreenHeight/2)-(Height/2) }